/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import hibernate.HibernateUtil;
import org.hibernate.Session;
import pojo.Account;
import pojo.Player;

/**
 *
 * @author Kenneth Veenstra <kenneth.veenstra@gmail.com>
 */
public class PlayerDao
{
    private Session session;
    public PlayerDao()
    {
    }

    public Player getPlayerById(Integer id)
    {
        session = HibernateUtil.getSessionFactory().openSession();
        org.hibernate.Transaction tx = null;
        Player player = null;
        try
        {
            tx = session.beginTransaction();
            player  = (Player) session.get(Player.class, id);
        }
        catch ( Exception e )
        {
            if ( tx != null )
            {
                tx.rollback();
            }
            e.printStackTrace();
        }
        finally
        {
            session.close();
        }
        return player;
    }

    public boolean UpdatePlayer(Player player)
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
